<template>
	<view v-if="show">
		<pxingExam :nownum='nownum' :submitType='submitType' :examlist='testlist' :paperId="paperId" :types="type"
			:Useranswer="mydata" :timeOut="time" @getEveryAnswer='getEveryAnswer' @getLastAnswer='getLastAnswer'>
		</pxingExam>
	</view>
</template>

<script>
	import pxingExam from '@/components/pxing-exam/pxing-exam.vue';
	export default {
		components: {
			pxingExam
		},
		data() {
			return {
				testlist: [],
				nownum: 0,
				submitType: 1, //0-一题一题提交，1-一次全部提交
				paperId: 0,
				type: 2,
				show: false,
				mydata: [],
				time: 0,
				ids: '',
				answerId: ''
			}
		},
		onLoad(params) {
			
			console.log(params);
			let newMap = JSON.parse(params.id)
			if (newMap.type != 3) {
				this.paperId = newMap.id
			} else {
				this.answerId = newMap.id
			}


			this.type = newMap.type
			this.getData();
		},
		methods: {
			getData() {
				if (this.type != 3) {
					uni.$u.http.get('/app/paper/index/' + this.paperId + '/' + this.type).then((res) => {

					
						this.testlist = res.data
						
					
						if (res.mydata) {
							this.mydata = res.mydata
						}
						if (res.time) {
							this.time = res.time
						}

						this.show = true
					})
				} else {
					uni.$u.http.get('/app/paper/getReallyShijun/' + this.answerId).then((res) => {


					
						this.testlist = res.data
						this.mydata = res.mydata



						this.show = true
					})
				}

			},
			getLastAnswer(e) {
				console.log(e)
			},
			getEveryAnswer(e) {
				uni.redirectTo({
					url: 'finish?id=' + e
				})
			}
		}
	}
</script>

<style>

</style>
